﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using TRPOP.CRM.Component.Business;
using TRPOP.CRM.Component.Common;
using TRPOP.CRM.Component.Model;
using TRPOP.Common;

namespace TRPOP.CRM.Web
{
    public partial class Company_view : BaseAdmin
    {
        #region 权限限制
        protected override void SubPageInit()
        {

        }
        #endregion

        #region 页面变量
        //记录传递参数CompanyID
        public int m_intCompanyID = 0;
        //添加客户
        public CompanyInfo m_oCompanyInfo = null;
        #endregion

        #region 页面事件
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindInfo();
                if (RequestHelper.RequestInt("id") > 0)
                {
                    m_intCompanyID = RequestHelper.RequestInt("id");
                    BindCompanyInfo();
                }
            }
        }
        #endregion

        #region 页面方法
        /// <summary>
        /// 绑定基础信息
        /// </summary>
        private void BindInfo()
        {
            //绑定客户状态信息
            PageBindHelper.BindCompanyStatus(ddlCompanyStatus);

            //绑定客户类型信息
            PageBindHelper.BindCompanyCategoryInfo(ddlCompanyCategory);

            //绑定客户等级信息
            PageBindHelper.BindCompanyGradeInfo(ddlCompanyGrade);

            //绑定客户来源信息
            PageBindHelper.BindCompanySourceInfo(ddlCompanySource);

            //绑定员工跟踪类型
            //PageBindHelper.BindFollowUpCategoryInfo(ddlEmployeeFollowup);
        }
        /// <summary>
        /// 绑定客户类型信息
        /// </summary>
        private void BindCompanyInfo()
        {
            m_oCompanyInfo = CompanyManage.GetCompanyInfo(m_intCompanyID);
            if (m_oCompanyInfo != null)
            {
                ViewState["CompanyInfo"] = m_oCompanyInfo;

                //客户的基本信息
                txtCompanyName.Text = m_oCompanyInfo.nvcCompanyName.Trim();
                txtCompanyName.Enabled = false;

                txtContactName.Text = m_oCompanyInfo.nvcContactName.Trim();
                txtContactName.Enabled = false;

                rbtnlstGender.SelectedValue = m_oCompanyInfo.bGender ? "1" : "0";

                txtDescription.Text = m_oCompanyInfo.nvcDiscription.Trim();

                ddlCompanyStatus.SelectedValue = m_oCompanyInfo.iCompanyStatus.ToString();

                ddlCompanyCategory.SelectedValue = m_oCompanyInfo.iCompanyCategoryID.ToString();

                ddlCompanyGrade.SelectedValue = m_oCompanyInfo.iCompanyGradeID.ToString();

                ddlCompanySource.SelectedValue = m_oCompanyInfo.iCompanySourceID.ToString();

                //客户联系方式
                txtRegisterAdress.Text = m_oCompanyInfo.nvcRegisterAdress.Trim();

                txtContactAddress.Text = m_oCompanyInfo.nvcContactAddress.Trim();
                txtCountry.Text = m_oCompanyInfo.nvcCountry.Trim();
                txtProvince.Value = m_oCompanyInfo.nvcProvince.Trim();
                txtCity.Value = m_oCompanyInfo.nvcCity.Trim();
                txtContactPhone.Text = m_oCompanyInfo.nvcContactPhone.Trim();
                txtContactTel.Text = m_oCompanyInfo.nvcContactTel.Trim();
                txtFax.Text = m_oCompanyInfo.nvcFax.Trim();
                txtEmail.Text = m_oCompanyInfo.nvcEmail.Trim();
                txtPostalCode.Text = m_oCompanyInfo.nvcPostCode.Trim();
                txtQQ.Text = m_oCompanyInfo.nvcQQ.Trim();
                txtWebSite.Text = m_oCompanyInfo.nvcWebSite.Trim();
            }
        }
        #endregion
    }
}